package com.chinasofti.controller;

import com.chinasofti.dao.EmployeeDao;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet("/approveServlet")
public class ApproveServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        int employeeid = Integer.parseInt(req.getParameter("employeeid"));
        String oper = req.getParameter("oper");
        EmployeeDao dao = new EmployeeDao();
        if(oper != null && oper.equals("yes")){
            dao.updateStatus(employeeid,"1");
            req.getRequestDispatcher("viewAllEmployeesServlet?code=approve").forward(req,resp);
        }
        if(oper != null && oper.equals("no")){
            dao.updateStatus(employeeid,"2");
            req.getRequestDispatcher("viewAllEmployeesServlet?code=approve").forward(req,resp);
        }
    }
}
